import React, { lazy, Suspense } from "react";
import { BrowserRouter as Router, Route, Redirect } from "react-router-dom";
import NavBar from "../components/navbar"
const Housepage = lazy(() => import("../pages/house"));
const Newspage = lazy(() => import("../pages/news"));
const Userpage = lazy(() => import("../pages/user"));

class RouterComponent extends React.Component {
    render() {
        return(
            
            <React.Fragment>
                <Router>
                <React.Fragment>
                <NavBar>
                </NavBar>
                <div className="main">
                <Suspense fallback={<div>loading</div>}>
                <Route path="/home/user" component={Userpage}></Route>
                <Route path="/home/house" component={Housepage}></Route>
                <Route path="/home/news" component={Newspage}></Route>
                <Route
                path="/home"
                exact
                render={() => <Redirect to="/home/user" />}
              ></Route>
                </Suspense>
                </div>
                </React.Fragment>
                </Router>
            </React.Fragment>
        )
    }
}
export  default RouterComponent;